using ApiDemo.Domain.Base;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace ApiDemo.Infrastructure.Persistence.Configuration.Base
{
    /// <summary>
    /// 基础实体类型配置（映射）
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseEntityConfiguration<T> : IEntityTypeConfiguration<T> where T:BaseEntity
    {
        public virtual void Configure(EntityTypeBuilder<T> builder)
        {
            builder.HasKey(x=>x.Id);

            builder.Property(x=>x.Id).HasColumnName("id").HasColumnOrder(0);
            builder.Property(x=>x.CreatedAt).HasColumnName("created_at").HasColumnOrder(992);
            builder.Property(x=>x.UpdatedAt).HasColumnName("updated_at").HasColumnOrder(993);
            builder.Property(x=>x.CreatedBy).HasColumnName("created_by").HasColumnOrder(994);
            builder.Property(x=>x.UpdatedBy).HasColumnName("updated_by").HasColumnOrder(995);
            builder.Property(x=>x.IsActived).HasColumnName("is_actived").HasColumnOrder(996);
            builder.Property(x=>x.IsDeleted).HasColumnName("is_deleted").HasColumnOrder(997);
            builder.Property(x=>x.DisplayOrder).HasColumnName("display_order").HasColumnOrder(998);
            builder.Property(t => t.Remarks).HasColumnName("remarks").HasMaxLength(800).HasColumnOrder(999);
        }
    }
}